<?php
$arr = [
    ["床","前","明","月","光"],
    ["疑","是","地","上","霜"],
    ["举","头","望","明","月"],
    ["低","头","思","故","乡"]
];
for($i=0;$i<count($arr[0]);$i++){//行
    echo "<div>";
    for($j=count($arr)-1;$j>=0;$j--){//列
        echo "<span>{$arr[$j][$i]}</span>";
    }
    echo "</div>";
}

echo "<hr>";
for($i=0;$i<count($arr);$i++){//行
    echo "<div>";
    for($j=0;$j<count($arr[0]);$j++){//列
        echo "<span>{$arr[$i][$j]}</span>";
    }
    echo "</div>";
}

echo "<hr>";
for($j=0;$j<count($arr[0]);$j++){//行
    echo "<div>";
    for($i=count($arr);$i>=0;$i--){//列
        echo "<span>{$arr[$i][$j]}</span>";
    }
    echo "</div>";
}

?>